package service.impl;

import dao.MasterDao;
import dao.impl.MasterDaoImpl;
import entity.Master;
import service.MasterService;

import java.util.List;

public class MasterServiceImpl implements MasterService{
    MasterDao masterDao=  new MasterDaoImpl();
    @Override
    public void login(String username, String userpassword)throws Exception {
        //实现登入功能
      Master master= masterDao.getMaster(username,userpassword);
      if (master!=null){
          System.out.println("登入成功");
      }else {
          System.out.println("登入失败");
      }
    }
    public void register(int userid,String username, String password)throws Exception{
        int i=masterDao.getmaster(userid,username,password);
            if (i>0){
                System.out.println("注册成功");
            }else {
                System.out.println("注册失败");
            }
        }
    public void update(String username, String password,String oldPassword)throws Exception{
        int i=masterDao.updeteMaster(username,password,oldPassword);
        if (i>0){
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
    }

    @Override
    public List<Master> getlist() throws Exception {
        MasterDao masterDao = new MasterDaoImpl();
        List<Master> getlist = masterDao.getlist();
        return getlist;
    }
}

